package com.hehua.ObserverPattern;

/**
 * @author paul
 * 具体指挥部类,充当具体目标类
 */
public class ConcreteAllyControlCenter extends AllyControlCenter {

    public ConcreteAllyControlCenter(String allyName) {
        System.out.println(allyName+"战队创建成功");
        System.out.println("-----------------------");
        this.allyName = allyName;
    }

    /**
     * 实现通知方法
     * @param name
     */
    @Override
    public void notifyObserver(String name) {
        System.out.println(this.allyName+"战队紧急通知,盟友"+name+"遭受敌人攻击");
        for (Observer obs : plays) {
            if (!(obs.getName().equalsIgnoreCase(name))){
                obs.help();
            }
        }
    }
}
